package com.lgCore.util;/**
 * Created by by on 2020/11/11 13:19
 */

import java.io.IOException;

/**
 * protobuf生成工具
 *@program: sxreader_rpc
 *@author: ligang
 *@create: 2020-11-11 13:19
 */
public class ExecProtobuf {
    public static void main(String[] args) throws IOException
    {
        String strCmd = "D:\\Program Files\\protobuf\\bin\\protoc " +
                " -I=D:\\workspacing\\sxreader_rpc\\protobuf\\src\\main\\resources\\protoFile " +
                " --java_out=D:\\workspacing\\sxreader_rpc\\protobuf\\src\\main\\resources\\protoFile User.proto ";

        StringBuffer stringBuffer = new StringBuffer();
        //执行语句
        stringBuffer.append("D:\\Program Files\\protobuf\\bin\\protoc ");

        //源地址
        stringBuffer.append(" -I=");
        stringBuffer.append("D:\\workspacing\\sxreader_rpc\\protobuf\\proto\\common ");

        //目标地址
        stringBuffer.append(" --java_out=");
        stringBuffer.append("D:\\workspacing\\sxreader_rpc\\protobuf\\src\\main\\java ");

        //文件名字
        stringBuffer.append(" ProtoMsg.proto");

//        protoc -I=源地址 --java_out=目标地址
//        protoc -I=D:\workspacing\sxreader_rpc\protobuf\src\main\resources\protoFile --java_out=D:\workspacing\sxreader_rpc\protobuf\src\main\resources\protoFile User.proto


//        protoc -I=D:\workspacing\sxreader_rpc\protobuf\src\main\resources\protoFile --java_out=D:\workspacing\sxreader_rpc\protobuf\src\main\resources\protoFile CommonRpcResponse.proto
        try{
            Runtime.getRuntime().exec(stringBuffer.toString());
        }catch (Exception e){
            e.printStackTrace();
        }

    }

}
